<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>2-5</title>

</head>
<body>

<div style=" " class="blank">
<a href="http://www.baidu.com" >123</a>
<a href="http://www.baidu.com" >123</a>
<a href="http://www.baidu.com" >123</a>
</div>

<div style=" " class="">
<a href="http://www.baidu.com" >123</a>
<a href="http://www.baidu.com" >123</a>
<a href="http://www.baidu.com" >123</a>
</div>

<script>
function ByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/-/g, "\-");
	var oRegExp = new RegExp("(^|\s)" + strClassName + "(\s|$)");	
	var oElement;	
	for(var i=0; i<arrElements.length; i++){	
	oElement = arrElements[i];	
	if(oRegExp.test(oElement.className)){	
	arrReturnElements.push(oElement);	
	  }	
	}
	return (arrReturnElements);
}

var blanks = ByClassName(document, "*", "blank");
for (var i=0;i<blanks.length;i++ ){  
	var urls = blanks[i].getElementsByTagName("a");
	for (var j=0;j<urls.length;j++ ){
		urls[j].target="_blank";   
	}
} 
</script>
</body>
</html>
